perm filename A99.TEX[106,RWF] blob
sn#834449 filedate 1987-02-11 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 \magnification\magstephalf
C00006 ENDMK
Cā;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a99.tex[106,phy] \today\hfill}
\font\rmn=cmr9
\bigskip
\line{\bf Interactive Input\hfil}
When a program is being executed, a user has no direct way to know what
the program is doing. If the program needs information from the user,
it must first display to the user a description of what it needs; doing
so is called {\it prompting}. The program then reads what the user types
at a keyboard. Because mistakes and misunderstandings by the user are
common, the program should check whether the user has typed valid information.
If not, the program should prompt again, perhaps in more detail than the
first time, and read again. When necessary, this cycle may be repeated
several times. It is simplest to prompt for, and read, one datum at a time.
A user may make mistakes in typing that result in wrong, yet valid, data.
It is important that the data be recorded so that such errors can be detected
afterward. A~good way to do so is to maintain a {\sl log\/}: a~file on which
is printed a copy of the first prompting message for each datum, and each
valid datum received from the user.
The following program fragment typifies getting a single item of information
from a user.
\medskip
{\obeylines\obeyspaces\let =\ \tt
WRITESCREEN('{\rm{Please enter year of birth}}');
READKEYS(BIRTHYEAR);
WHILE (BIRTHYEAR<1880) OR (BIRTHYEAR>1986) DO
BEGIN
WRITESCREEN('{\rm{Please type your year of birth as a number between 1880 and 1986}}');
READKEYS(BIRTHYEAR)
END;
WRITELN(LOGFILE,'BIRTHYEAR=',BIRTHYEAR)
}
\bigskip
\line{\copyright 1987 Robert W. Floyd;
First draft (not published) February 11, 1987\hfil}
%revised: Date; subsequently revised.\hfill}
\bye